#!/bin/sh

# Enable i2c
raspi-config nonint do_i2c 0

if [ -e /usr/share/debconf/confmodule ]; then
  . /usr/share/debconf/confmodule

  db_get pisugar-poweroff/model
  OPTS="$OPTS --model '$RET'"

  db_get pisugar-poweroff/countdown
  OPTS="$OPTS --countdown $RET"

  echo "OPTS=$OPTS" > /etc/default/pisugar-poweroff
fi

deb-systemd-helper unmask pisugar-poweroff.service >/dev/null || true
if deb-systemd-helper --quiet was-enabled pisugar-poweroff.service; then
  deb-systemd-helper enable pisugar-poweroff.service >/dev/null || true
else
  deb-systemd-helper update-state pisugar-poweroff.service >/dev/null || true
fi
